﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using IOEntity;
using IOBusiness;
using System.Xml;
namespace Indochinaodyssey.UserControl.Tour
{
    public partial class ucTourDetail : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                IOBusiness.clsBSDetail obj = new IOBusiness.clsBSDetail();
                List<clsDetail> objD = new List<clsDetail>();
                objD=obj.GetByTour(Convert.ToInt32(Request.QueryString["id"]));
                foreach (IOEntity.clsDetail item in objD)
                {
                    IOBusiness.clsBSTypeDetail type = new IOBusiness.clsBSTypeDetail();
                    IOEntity.clsTypeDetail typeobj = new IOEntity.clsTypeDetail();
                    typeobj = type.GetById(item.TypeDetail.Id);
                    AjaxControlToolkit.TabPanel tab = new AjaxControlToolkit.TabPanel();
                    tab.HeaderText = typeobj.TieuDe;
                    Label lb = new Label();
                    lb.Text = item.NoiDung;
                    tab.Controls.Add(lb);
                    this.TabContainer1.Tabs.AddAt(0,tab);
                    //this.TabContainer1.Tabs[1]
                }
                this.TabContainer1.Tabs.RemoveAt(objD.Count);
                clsBSTour objtour = new clsBSTour();
                clsTour t = new clsTour();
                t = objtour.GetById(Convert.ToInt32(Request.QueryString["id"]));
                this.lblTour.Text = t.TieuDe;
                this.Label1.Text = t.TieuDe;
                this.DataList2.DataSource = objtour.GetByLoai(t.TheLoai.Id, Convert.ToInt32(Request.QueryString["id"]));
                DataList2.DataBind();
                if (!Page.IsPostBack)
                {
                    BindCountry();
                }
            }
            catch (Exception)
            {

                throw;
            }
        }
        private void BindCountry()
        {
            XmlDocument doc = new XmlDocument();
            doc.Load(Server.MapPath("~/XML/country.xml"));

            foreach (XmlNode node in doc.SelectNodes("countries/country"))
            {
                ddlContry.Items.Add(new ListItem(node.InnerText, node.Attributes["code"].InnerText));
                ddlContry.DataBind();
            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            try
            {
                String str = "<div>Full Name :" + this.DropDownList1.SelectedValue + " " + this.txtFullName.Text + 
                    "<br />Address :" + this.txtAddress.Text + "<br />Phone :&nbsp;" + this.txtTelephone.Text + 
                    "<br />Email :" + this.txtEmailAddress.Text + 
                    "<br />Mobile Phone :" + this.txtMonbile.Text + 
                    "<br />Country :" + this.ddlContry.SelectedItem.Text +
                    "<br />Single(s) :" + this.ddlSingle.SelectedItem.Text + 
                    " - Double(s) :" + this.ddlDouble.SelectedItem.Text +
                     " - Twin(s) :" + this.ddlTwin.SelectedItem.Text +
                     "<br />" + this.ddlAll.SelectedItem.Text +
                     "<br /> Adults" + this.ddlAdults.SelectedItem.Text +
                     "<br /> - Children (< 6 years old) " + this.ddlChild1.SelectedItem.Text +
                     "<br /> - Children (6 -12 years old)  " + this.ddlChild2.SelectedItem.Text +
                     "<br /> - Children (> 12 years old)  " + this.ddlChild3.SelectedItem.Text +
                     "<br /> Check In From : " + this.txtCheckFrom.Text +
                     " - Check Out On :  " + this.txtCheckOn.Text +
                    "<br />Tour :" + this.lblTour.Text + "</div>"
                    ;
                string[] to = { "booking@halongbaycruises.net" };
                clsBSSendMail.sendMail(to, "Mail ContactUS from indochinaodyssey : " + this.DropDownList1.SelectedValue + " " + this.txtFullName.Text, str);
                Response.Redirect("~/ThankYouContact.aspx");
            }
            catch (Exception)
            {
            }
        }
    }
}